package com.example.agriapp.view.fragment;

import android.app.ProgressDialog;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import androidx.appcompat.app.AlertDialog;

import com.example.agriapp.R;
import com.example.agriapp.base.BaseFragment;

public class PublishFragment extends BaseFragment  {
    private Button mBtnPublishProduct;
    private Button mBtnPublishPurchase;
    private ProgressDialog mProgressDialog;

    public static PublishFragment newInstance() {
        return new PublishFragment();
    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_publish;
    }

    @Override
    protected void initView(View view) {

    }

    @Override
    protected void initData() {

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View root = inflater.inflate(R.layout.fragment_publish, container, false);
        
        initViews(root);
        initPresenter();
        
        return root;
    }

    private void initViews(View root) {
        mBtnPublishProduct = root.findViewById(R.id.btn_publish_product);
        mBtnPublishPurchase = root.findViewById(R.id.btn_publish_purchase);
        
        mBtnPublishProduct.setOnClickListener(v -> navigateToPublishProduct());
        mBtnPublishPurchase.setOnClickListener(v -> navigateToPublishPurchase());
        
        // 根据用户类型显示不同的提示
//        if (UserTypeUtils.isSeller()) {
//            mBtnPublishProduct.setText("发布商品");
//            mBtnPublishPurchase.setText("发布采购需求");
//        } else {
//            mBtnPublishProduct.setText("发布农产品");
//            mBtnPublishPurchase.setText("发布求购信息");
//        }
    }

    private void initPresenter() {
//        mPresenter = new PublishPresenter(this, new PublishRepository());
//        mPresenter.checkPublishPermission();
    }

    private void navigateToPublishProduct() {
        if (getActivity() != null) {
//            Intent intent = new Intent(getActivity(), PublishProductActivity.class);
//            startActivity(intent);
        }
    }

    private void navigateToPublishPurchase() {
        if (getActivity() != null) {
//            Intent intent = new Intent(getActivity(), PublishPurchaseActivity.class);
//            startActivity(intent);
        }
    }


}